package com.sfh.cpc.com.entity;

import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.RequiresApi;
import android.text.TextUtils;

import com.sfh.cpc.com.BaseAppContent;

import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;

/**
 * 功能描述: 话题
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/7
 */
public class ENote implements Parcelable{

    /**
     * 判断是否已点赞
     */
    boolean fabulous;

    long noteId;
    long userId;//"创建者ID
    long massId;//"社团ID
    String noteContent;//"内容
    String noteLable;//"标签"
    long noteReadiSize;//"阅读量"
    long noteMsgSize;//"评论量"
    long noteFabulousSize;//"点赞量"
    String noteCreateTime;//"创建时间"
    String noteVip;//"特权查看 1:需要否则不需要"
    long noteConsumeWealth;
    List<String> images;
    EUser user;


    protected ENote(Parcel in) {
        fabulous = in.readByte() != 0;
        noteId = in.readLong();
        userId = in.readLong();
        massId = in.readLong();
        noteContent = in.readString();
        noteLable = in.readString();
        noteReadiSize = in.readLong();
        noteMsgSize = in.readLong();
        noteFabulousSize = in.readLong();
        noteVip = in.readString();
        images = in.createStringArrayList();
        user = in.readParcelable(EUser.class.getClassLoader());
        noteCreateTime =  in.readString();
        noteConsumeWealth = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (fabulous ? 1 : 0));
        dest.writeLong(noteId);
        dest.writeLong(userId);
        dest.writeLong(massId);
        dest.writeString(noteContent);
        dest.writeString(noteLable);
        dest.writeLong(noteReadiSize);
        dest.writeLong(noteMsgSize);
        dest.writeLong(noteFabulousSize);
        dest.writeString(noteVip);
        dest.writeStringList(images);
        dest.writeParcelable(user, flags);
        dest.writeString(noteCreateTime);
        dest.writeLong(noteConsumeWealth);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ENote> CREATOR = new Creator<ENote>() {
        @Override
        public ENote createFromParcel(Parcel in) {
            return new ENote(in);
        }

        @Override
        public ENote[] newArray(int size) {
            return new ENote[size];
        }
    };

    public boolean isFabulous() {
        return fabulous;
    }

    public long getNoteId() {
        return noteId;
    }

    public long getUserId() {
        return userId;
    }

    public long getMassId() {
        return massId;
    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    public String getNoteContent() {

        return BaseAppContent.decode(noteContent);
    }

    public String getNoteLable() {

        return BaseAppContent.decode(noteLable);
    }

    public long getNoteReadiSize() {
        return noteReadiSize;
    }

    public long getNoteMsgSize() {
        return noteMsgSize;
    }

    public long getNoteFabulousSize() {
        return noteFabulousSize;
    }

    public String getNoteCreateTime() {
        return noteCreateTime;
    }

    public String getNoteVip() {
        return noteVip;
    }

    public List<String> getImages() {
        return images;
    }

    public EUser getUser() {
        return user;
    }

    public void setNoteMsgSize(long size) {
        this.noteMsgSize =size;
    }

    public void setFabulous(boolean b) {
        this.fabulous = b;
    }

    public long getNoteConsumeWealth() {
        return noteConsumeWealth;
    }

    public void setNoteVip(String noteVip) {
        this.noteVip = noteVip;
    }
}
